<extend name="Public/base" />
<block name="body">
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>供应商收入管理</h2>
    </div>


    <!-- 数据列表 -->
        <div class="money">


            <div class="search-money">

                <form class="search-form fr cf">
                <div class="">
                    <div class="search-money-num" style="float:left;margin-right:5px;">
                        <select name="status" style="float:left;line-height:30px;height:32px;margin-right:5px;">
                            <option value="">请选择订单状态</option>
                            <option value="2" <eq name="selectstatus" value="2">selected</eq> >待付款</option>
                            <option value="3" <eq name="selectstatus" value="3">selected</eq>>待发货</option>
                            <option value="4" <eq name="selectstatus" value="4">selected</eq>>已发货</option>
                            <option value="5" <eq name="selectstatus" value="5">selected</eq>>待评价</option>
                            <option value="1" <eq name="selectstatus" value="1">selected</eq>>已完成</option>
                            <option value="10" <eq name="selectstatus" value="10">selected</eq>>已取消</option>
                        </select>
                        <select name="supplier_id" style="float:left;line-height:30px;height:32px;margin-right:5px;" id="supplier_id">
                            <option value="">请选择供应商</option>
                            <foreach name="supplierlist" key="key" item="val">
                                <if condition="$val['uid'] eq $selectsupplier">
                                    <option value="{$val.uid}" selected>{$val.nickname}</option>
                                    <else />
                                    <option value="{$val.uid}">{$val.nickname}</option>
                                </if>
                            </foreach>
                        </select>
                        <select name="good_id" id="good_id" style="float:left;line-height:30px;height:32px;margin-right:5px;">
                            <option value="">请选择商品</option>
                        </select>
                        <div class="controls" style="float:left;line-height:32px;height:34px;margin-right:5px;">
                            <notempty name="start_time">
                                <input type="text" class="text date_picker"  style="float:left;line-height:32px;margin-right:5px;" placeholder="开始时间"  name="start_time" value="{$start_time}">
                                <else />
                                <input type="text" class="text date_picker"  style="float:left;line-height:32px;margin-right:5px;" placeholder="开始时间"  name="start_time" value="">
                            </notempty>
                        </div>
                        <div class="controls" style="float:left;line-height:32px;height:34px;margin-right:5px;">
                            <notempty name="end_time">
                                <input type="text" class="text date_picker"  style="float:left;line-height:32px;margin-right:5px;" placeholder="结束时间"  name="end_time" value="{$end_time}">
                                <else />
                                <input type="text" class="text date_picker"  style="float:left;line-height:32px;margin-right:5px;" placeholder="结束时间"  name="end_time" value="">
                            </notempty>
                        </div>
                    </div>
                    <input type="hidden"  name="search" value="1">
                    <a class="sch-btn" href="javascript:;" id="search" url="admin.php?s=/Money/supplier.html"><i class="btn-search"></i></a>
                    <a class="" href="javascript:;" id="search_data" url="admin.php?s=/Money/downloadexcel.html">导出数据</a>
                </div>
                </form>
            </div>
            <div class="data-table">
                <table>
                    <!-- 表头 -->
                    <thead>
                    <tr>
                        <th>供应商名称</th>
                        <th>商品名称</th>
                        <th>件数</th>
                        <th>金额</th>
                        <th>操作时间</th>
                        <th>订单状态</th>
                    </tr>
                    </thead>
                    <!-- 列表 -->
                    <tbody>
                    <notempty name="_list">
                        <volist name="_list" id="vo">
                            <tr>
                                <td>{$vo.supplier_name} </td>
                                <td>{$vo.good_name}</td>
                                <td>{$vo.count}</td>
                                <td>{$vo.amount}</td>
                                <td>{$vo.create_time}</td>
                                <td>{$vo.status_name}</td>
                            </tr>
                        </volist>
                        <else/>
                        <td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
                    </notempty>
                    </tbody>
                </table>
            </div>
            <div class="page">
                {$_page}
            </div>
</div>
</block>
<block name="style">
    <link href="__PUBLIC__/static/jquery-datetimepicker/jquery-datetimepicker.css" rel="stylesheet" media="screen">
    <link rel="stylesheet" href="__PUBLIC__/static/kindeditor/default/default.css" />
</block>
<block name="script">
    <script type="text/javascript" src="__PUBLIC__/static/jquery-datetimepicker/jquery-datetimepicker.js"></script>
    <script type="text/javascript" charset="utf-8">
        //搜索功能
        $("#search").click(function(){
            var url = $(this).attr('url');
            var query  = $('.search-form').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
            query = query.replace(/^&/g,'');
            if( url.indexOf('?')>0 ){
                url += '&' + query;
            }else{
                url += '?' + query;
            }
            window.location.href = url;
        });
        $("#search_data").click(function(){
            var url = $(this).attr('url');
            var query  = $('.search-form').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
            query = query.replace(/^&/g,'');
            if( url.indexOf('?')>0 ){
                url += '&' + query;
            }else{
                url += '?' + query;
            }
            window.location.href = url;
        });
        //回车搜索
        $(".search-input").keyup(function(e){
            if(e.keyCode === 13){
                $("#search").click();
                return false;
            }
        });
        //日期时间插件
        $('.date_picker').datetimepicker({
            lang:'ch',
            format:'Y-m-d H:00',
            timepicker:true,
            allowBlank:true
        });
        var supplier_id = $("#supplier_id").val();
        var selectgood_id = {$selectgood_id};
        if(supplier_id != 0){
            $.post(
                    'admin.php?s=/Money/goodlist.html',
                    {
                        supplier_id: supplier_id
                    },
                    function(responed){
                        var list = '<option value="">请选择商品</option>';
                        if(responed != ""){
                            var jsondata = eval('(' + responed + ')');
                            for(x in jsondata){
                                if(selectgood_id == jsondata[x].id){
                                    list += '<option value="'+jsondata[x].id+'" selected>'+jsondata[x].title+'</option>';
                                }else{
                                    list += '<option value="'+jsondata[x].id+'">'+jsondata[x].title+'</option>';
                                }
                            }
                        }else{
                            alert("该供应商无商品");
                        }
                        $("#good_id").html(list);
                    }
            );
        }

        $("#supplier_id").change(function(){
            var supplier_id = $(this).val();
            $.post(
                    'admin.php?s=/Money/goodlist.html',
                    {
                        supplier_id: supplier_id
                    },
                    function(responed){
                        var list = '<option value="">请选择商品</option>';
                        if(responed != ""){
                            var jsondata = eval('(' + responed + ')');
                            for(x in jsondata){
                                if(selectgood_id == jsondata[x].id){
                                    list += '<option value="'+jsondata[x].id+'" selected>'+jsondata[x].title+'</option>';
                                }else{
                                    list += '<option value="'+jsondata[x].id+'">'+jsondata[x].title+'</option>';
                                }
                            }
                        }
                        $("#good_id").html(list);
                    }
            );
        })
        //导航高亮
        highlight_subnav('{:U('Trader/traderList')}');
    </script>
</block>